home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-15 / phbench.zip / BENCHMUL.C < prev    next >
Text File  |  1993-01-04  |  1KB  |  32 lines

  1. /* benchmul - benchmark for  int multiply
  2.  * Thomas Plum, Plum Hall Inc, 609-927-3770
  3.  * If machine traps overflow, use an  unsigned  type
  4.  * Let  T  be the execution time in milliseconds
  5.  * Then  average time per operator  =  T/major  usec
  6.  * (Because the inner loop has exactly 1000 operations)
  7.  */
  8. #define STOR_CL auto
  9. #define TYPE int
  10. #include <stdio.h>
  11. main(ac, av)
  12.         int ac;
  13.         char *av[];
  14.         {
  15.         STOR_CL TYPE a, b, c;
  16.         long d, major, atol();
  17.         static TYPE m[10] = {0};
  18.  
  19.         major = atol(av[1]);
  20.         printf("executing %ld iterations\n", major);
  21.         a = b = (av[1][0] - '0');
  22.         for (d = 1; d <= major; ++d)
  23.                 {
  24.                 /* inner loop executes 1000 selected operations */
  25.                 for (c = 1; c <= 40; ++c)
  26.                         {
  27.                         a = 3 *a*a*a*a*a*a*a*a * a*a*a*a*a*a*a*a * a*a*a*a*a*a*a*a * a; /* 25 * */
  28.                         }
  29.                 }
  30.         printf("a=%d\n", a);
  31.         }
  32.